<?php
App::import('Vendor', 'CKEditor', array('file' => 'ckeditor_php5.php'));

class CkHelper extends AppHelper {
	var $helpers = array('Form');

	function input($fieldName, $options = array()) { 
		
		$options = $this->_initInputField($fieldName, $options); 
		
		$value = null; 
		$config = array(
			'width'		=> '100%',
			'height'	=> '200px',
			'escape'	=> false,			
			'toolbar'	=> 'Basic',
			'skin'		=> 'v2'
		); 
		
		$events = null; 

		if (array_key_exists('value', $options)) { 
			$value = $options['value']; 
			/*
			if (!array_key_exists('escape', $options) || $options['escape'] !== false) { 
				$value = h($value); 
			} 
			*/
			unset($options['value']); 
		} 
		
		if (array_key_exists('config', $options)) { 
			$config = $options['config']; 
			unset($options['config']); 
		} 
		
		if (array_key_exists('events', $options)) { 
			$events = $options['events']; 
			unset($options['events']); 
		} 

		$CKEditor = new CKEditor(); 
		$CKEditor->returnOutput = true;
		$CKEditor->basePath = $this->webroot('js/ckeditor/'); 

		return $CKEditor->editor($options['name'], $value, $config, $events); 
	} 
}
?>
